package unlockpdf;

import java.io.IOException;
import java.lang.reflect.Field;

import com.lowagie.text.pdf.PdfReader;

public class UnLockPDF {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PdfReader reader;
		try {
			reader = new PdfReader("F:/Workspace/ItextPDFDemo/pdffolder/个人信用报告_encrypt.pdf");
			System.out.println(reader);
			unlockPdf(reader);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
	
	public static void unlockPdf(PdfReader reader)
	  {
	    try
	    {
	      if (reader != null)
	      {
	        Field f = reader.getClass().getDeclaredField("encrypted");
	        f.setAccessible(true);
	        f.set(reader, false);
	      }
	    } catch (Exception e)
	    {
	      e.printStackTrace();
	    }
	  }

}
